/*
 * @(#)MaintContactPersonForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.contact.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import com.dcivision.contact.bean.ContactList;
import com.dcivision.contact.bean.ContactPerson;
import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;

/**
  MaintContactPersonForm.java

  This class is the for web form purpose.

  @author           Jenny Li
  @company          DCIVision Limited
  @creation date    04/01/2005
  @version          $Revision: 1.13 $
*/

public class MaintContactPersonForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.13 $";

  private String ownerID = null;
  private String firstName = null;
  private String lastName = null;
  private String phoneNo = null;
  private String mobileNo = null;
  private String faxNo = null;
  private String email = null;
  private String remarks = null;
  private String title = null;
  private String department = null;
  private String publicFlag = ContactList.SHARING_TYPE_PUB;
  private String description = null;
  
  private String[] shareToUserIDs = null;
  private String[] shareToUserRoles = null;
  private String[] shareToUserGroups = null;
  
  private String contactListName = null;
  
  private FormFile uploadFile =null;

  public MaintContactPersonForm() {
    super();
  }

  public String getOwnerID() { 
    return(this.ownerID);
  }

  public void setOwnerID(String ownerID) { 
    this.ownerID = ownerID;
  }

  public String getFirstName() { 
    return(this.firstName);
  }

  public void setFirstName(String firstName) { 
    this.firstName = firstName;
  }

  public String getLastName() { 
    return(this.lastName);
  }

  public void setLastName(String lastName) { 
    this.lastName = lastName;
  }

  public String getPhoneNo() { 
    return(this.phoneNo);
  }

  public void setPhoneNo(String phoneNo) { 
    this.phoneNo = phoneNo;
  }

  public String getMobileNo() { 
    return(this.mobileNo);
  }

  public void setMobileNo(String mobileNo) { 
    this.mobileNo = mobileNo;
  }

  public String getFaxNo() { 
    return(this.faxNo);
  }

  public void setFaxNo(String faxNo) { 
    this.faxNo = faxNo;
  }

  public String getEmail() { 
    return(this.email);
  }

  public void setEmail(String email) { 
    this.email = email;
  }

  public String getRemarks() { 
    return(this.remarks);
  }

  public void setRemarks(String remarks) { 
    this.remarks = remarks;
  }

  public String getTitle() { 
    return(this.title);
  }

  public void setTitle(String title) { 
    this.title = title;
  }

  public String getDepartment() { 
    return(this.department);
  }

  public void setDepartment(String department) { 
    this.department = department;
  }

  public String getPublicFlag() { 
    return(this.publicFlag);
  }

  public void setPublicFlag(String publicFlag) { 
    this.publicFlag = publicFlag;
  }
  
  public String getDescription(){
    return this.description; 
  }
  
  public void setDescription(String description){
    this.description=description; 
  }
  
  public String[] getShareToUserIDs() {
    return this.shareToUserIDs;
  }

  public void setShareToUserIDs(String[] shareToUserIDs) {
    this.shareToUserIDs = shareToUserIDs;
  }

  public String[] getShareToUserRoles() {
    return this.shareToUserRoles;
  }

  public void setShareToUserRoles(String[]  shareToUserRoles) {
    this.shareToUserRoles = shareToUserRoles;
  }

  public String[] getShareToUserGroups() {
    return this.shareToUserGroups;
  }

  public void setShareToUserGroups(String[] shareToUserGroups) {
    this.shareToUserGroups = shareToUserGroups;
  }
  
  public String getContactListName(){
    return this.contactListName; 
  }
  
  public void setContactListName(String contactListName){
    this.contactListName=contactListName; 
  }
  
  public void setUploadFile(FormFile uploadFile) {
    this.uploadFile = uploadFile;
  }

  public FormFile getUploadFile() {
    return uploadFile;
  }
 
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setOwnerID(null);
    this.setFirstName(null);
    this.setLastName(null);
    this.setPhoneNo(null);
    this.setMobileNo(null);
    this.setFaxNo(null);
    this.setEmail(null);
    this.setRemarks(null);
    this.setTitle(null);
    this.setDepartment(null);
    this.setDescription(null);
    this.setPublicFlag(ContactList.SHARING_TYPE_PUB);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    ContactPerson tmpContactPerson = new ContactPerson();
    tmpContactPerson.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpContactPerson.setOwnerID(TextUtility.parseIntegerObj(this.getOwnerID()));
    tmpContactPerson.setFirstName(this.getFirstName());
    tmpContactPerson.setLastName(this.getLastName());
    tmpContactPerson.setPhoneNo(this.getPhoneNo());
    tmpContactPerson.setMobileNo(this.getMobileNo());
    tmpContactPerson.setFaxNo(this.getFaxNo());
    tmpContactPerson.setEmail(this.getEmail());
    tmpContactPerson.setRemarks(this.getRemarks());
    tmpContactPerson.setTitle(this.getTitle());
    tmpContactPerson.setDepartment(this.getDepartment());
    tmpContactPerson.setPublicFlag(this.getPublicFlag());
    tmpContactPerson.setRecordStatus(this.getRecordStatus());
    tmpContactPerson.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpContactPerson.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpContactPerson.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpContactPerson.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpContactPerson.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpContactPerson;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    ContactPerson tmpContactPerson = (ContactPerson)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpContactPerson.getID()));
    this.setOwnerID(TextUtility.formatIntegerObj(tmpContactPerson.getOwnerID()));
    this.setFirstName(tmpContactPerson.getFirstName());
    this.setLastName(tmpContactPerson.getLastName());
    this.setPhoneNo(tmpContactPerson.getPhoneNo());
    this.setMobileNo(tmpContactPerson.getMobileNo());
    this.setFaxNo(tmpContactPerson.getFaxNo());
    this.setEmail(tmpContactPerson.getEmail());
    this.setRemarks(tmpContactPerson.getRemarks());
    this.setTitle(tmpContactPerson.getTitle());
    this.setDepartment(tmpContactPerson.getDepartment());
    this.setPublicFlag(tmpContactPerson.getPublicFlag());
    this.setRecordStatus(tmpContactPerson.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpContactPerson.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpContactPerson.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpContactPerson.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpContactPerson.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpContactPerson.getUpdateDate()));
  }
}
